package com.linewell.commom.dao.impl;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.linewell.commom.dao.IFeedBackDao;
import com.linewell.commom.model.FeedBack;

/**
 * 具体实现
 */
@Repository
public class FeedBackDaoImpl extends BaseDaoImpl<FeedBack> implements IFeedBackDao {

	@Override
	public boolean removeAll(String ids) {
		String hql = "update FeedBack s set s.status = 0 where s.id in (" + ids + ") ";
		Query query = super.sessionFactory.getCurrentSession().createQuery(hql);
		return (query.executeUpdate() > 0);
	}

	@Override
	public boolean updateAll(FeedBack f,Integer integer) {
		StringBuffer hql = new StringBuffer("update FeedBack s set ");
		
		hql.append("  s.updateTime = now() ");
		
		// 拼接修改条件
		if (f.getReturContent() != null ) {
			hql.append(" , s.returContent = '" + f.getReturContent() + "' ");
		}

		hql.append(" , s.sysUsers.userId = " + integer  + " ");

		
		if(f.getStatus() != null && !"".equals(f.getStatus())){
			hql.append(" , s.status = "+f.getStatus()+" ");
		}

		
		
		hql.append(" where s.id =" + f.getId() + " ");
		Query query = super.sessionFactory.getCurrentSession().createQuery(hql.toString());
		return (query.executeUpdate() > 0);
	}

	
}
